package cn.javazd.udp;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UdpReceive {

	public static void main(String[] args) {
		try {
			DatagramSocket datagramSocket = new DatagramSocket(9090);
			byte[] buf = new byte[1024];
			DatagramPacket datagramPacket = new DatagramPacket(buf, buf.length);
			datagramSocket.receive(datagramPacket);
			System.out.println("receive data: " + new String(buf, 0, datagramPacket.getLength()));
			datagramSocket.close();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
